package com.wangyadong.hobby.schedule.jobtask.dataa;

/**
 * <p>
 *
 * @author <714037465@qq.com>
 * @since 2018/10/2415:46
 **/
public class FibImpl {

    public static void main(String[] args) {
        double v = doublefibImpl(70);
        System.out.println(v);
    }


    private static double doublefibImpl(int n) {
        if (n < 0) throw new IllegalArgumentException("must be >0");
        if (n == 0d) return 0d;
        if (n == 1) return 1d;
        double v = doublefibImpl(n - 2) + doublefibImpl(n - 1);
        if (Double.isInfinite(v)) throw new ArithmeticException("Over flow");
        return v;
    }


    private static long doublefibImpl2(int n) {
        long pre = 1l;
        long next = 1l;
        if (n < 0) throw new IllegalArgumentException("must be >0");
        if (n == 0d) return 0l;
        if (n == 1) return 1l;
        for (int i = 0; i < 3; i++) {

        }
        return 0;
    }
}
